import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './vuex'
import $ from 'jquery'
import { DatePicker} from 'element-ui';
import api from "./api.js"
import audio from "./audio.js"
window.$ = $;
document.oncontextmenu = function(){
    　　return false;
    }
document.addEventListener('DOMContentLoaded', function (event) {
    // chrome 浏览器直接加上下面这个样式就行了，但是ff不识别
    document.body.style.zoom = 'reset';
    document.addEventListener('keydown', function (event) {
        if ((event.ctrlKey === true || event.metaKey === true)
            && (event.which === 61 || event.which === 107
                || event.which === 173 || event.which === 109
                || event.which === 187 || event.which === 189)) {
            event.preventDefault();
        }
    }, false);
    document.addEventListener('mousewheel DOMMouseScroll', function (event) {
        if (event.ctrlKey === true || event.metaKey) {
            event.preventDefault();
        }
    }, false);
}, false);

Vue.config.productionTip = false;
Vue.use(DatePicker);
Vue.prototype.api = api; // 挂载api
Vue.prototype.ajax=$.ajax;
Vue.prototype.audio=audio;
/* eslint-disable no-new */
Vue.directive("logo-ray",{
  inserted(el){
    let canvas=document.createElement("canvas");
    let w=el.clientWidth*1.5;
    let h=el.clientHeight*1.5;
    canvas.width=w;
    canvas.height=h;
    canvas.style.width=el.clientWidth+"px";
    canvas.style.height=el.clientHeight+"px";
    el.appendChild(canvas);
    let getCanvas=canvas.getContext("2d");
    let i=new Image();
    i.src=require("@/assets/img/ray.png");
    i.onload=function(){
      let x=-90;
      getCanvas.drawImage(i,x,0,w,h);
      setInterval(()=>{
        x++;
        if(x>w){
          x=-90;
        }
        getCanvas.clearRect(0,0,w,h);
        getCanvas.drawImage(i,x,0,w,h);
      },8)
    }
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
